<?php

use yii\db\Migration;

class m240417_014729_diandi_hotel_order_contract extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%diandi_hotel_order_contract}}', [
            'id' => "int(11) NOT NULL AUTO_INCREMENT",
            'bloc_id' => "int(11) NULL COMMENT '公司id'",
            'store_id' => "int(11) NULL COMMENT '商户id'",
            'hotel_id' => "int(11) NULL COMMENT '酒店id'",
            'room_id' => "int(11) NULL COMMENT '房间id'",
            'order_id' => "int(11) NULL COMMENT '订单ID'",
            'create_time' => "datetime NULL COMMENT '创建时间'",
            'update_time' => "datetime NULL COMMENT '更新时间'",
            'status' => "int(11) NULL COMMENT '状态'",
            'content' => "text NULL COMMENT '协议内容'",
            'user_sign' => "int(11) NULL COMMENT '用户签名状态'",
            'landlord_id' => "int(11) NULL COMMENT '房东id'",
            'landlord_sign' => "int(11) NULL COMMENT '房东签名状态'",
            'member_id' => "int(11) NULL COMMENT '会员ID'",
            'user_sign_img' => "varchar(255) NULL COMMENT '用户签名图片'",
            'landlord_sign_img' => "varchar(255) NULL COMMENT '房东签名图片'",
            'user_sign_time' => "datetime NULL COMMENT '用户签名时间'",
            'landlord_sign_time' => "datetime NULL COMMENT '房东签名时间'",
            'PRIMARY KEY (`id`)'
        ], "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='长租协议'");
        
        /* 索引设置 */
        
        
        /* 表数据 */
        
        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

    public function down()
    {
        $this->execute('SET foreign_key_checks = 0');
        /* 删除表 */
        $this->dropTable('{{%diandi_hotel_order_contract}}');
        $this->execute('SET foreign_key_checks = 1;');
    }
}

